package com.bigShen.pattern.prototype.reflectClone;

import com.bigShen.pattern.prototype.JinGuBang;

/**
 * Created by lei.shen on 2018/9/24.
 */
public class MainTestReflect {

    public static void main(String[] args) {

        ReflectQiTianDaSheng qiTianDaSheng = new ReflectQiTianDaSheng();
        JinGuBang jinGuBang = new JinGuBang();
        jinGuBang.setWeight(10);
        jinGuBang.setHeight(200);

        qiTianDaSheng.setJinGuBang(jinGuBang);
        qiTianDaSheng.setName("齐天大圣");
        qiTianDaSheng.setType("六耳猕猴");
        qiTianDaSheng.setLocation("China");

        System.out.println("原对象 " +  qiTianDaSheng);

        try {
            ReflectQiTianDaSheng clone = (ReflectQiTianDaSheng) qiTianDaSheng.clone();
            System.out.println("克隆体" + clone);
            System.out.println("修改克隆体金箍棒变大!");
            clone.getJinGuBang().big();
            System.out.println("原对象金箍棒 " + qiTianDaSheng.getJinGuBang());
            System.out.println("克隆体金箍棒 " + clone.getJinGuBang());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }

    }

}
